package reflect;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class ReflectDemo2 {
    public static void main(String[] args) throws InstantiationException, IllegalAccessException, ClassNotFoundException {
        ArrayList list = new ArrayList();
        System.out.println(list);

        //Class cls = ArrayList.class;

        //Class cls = Class.forName("java.util.ArrayList");

        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入一个类名：");
        String className = scanner.nextLine();
        Class cls = Class.forName(className);

        Object obj = cls.newInstance();
        System.out.println(obj);


    }
}
